import moment from "moment";

export default function getTime() {
  var now = new Date(); // 获取当前时间
  let time;
  if (now.getHours() < "15") {
    // 三点后，计算明天的日期
    let date = moment().format("YYYY-MM-DD") + " 15:00:00";
    time = date;
  } else {
    var y = now.getFullYear();
    var m = now.getMonth() + 1;
    var lastDay = new Date(y, m, 0);
    lastDay = lastDay.getDate();
    // 判断是否本月最后一天/本年度最后一月
    if (lastDay == now.getDate()) {
      if (m == "12") {
        let date = moment()
          .year(now.getFullYear() + 1)
          .month(1)
          .date(1)
          .hour(15)
          .minute(0)
          .second(0)
          .millisecond(0);
        time = date;
      } else {
        let date = moment()
          .year(now.getFullYear())
          .month(now.getMonth() + 1)
          .date(1)
          .hour(15)
          .minute(0)
          .second(0)
          .millisecond(0);
        time = date;
      }
    } else {
      let date = moment()
        .year(now.getFullYear())
        .month(now.getMonth())
        .date(now.getDate() + 1)
        .hour(15)
        .minute(0)
        .second(0)
        .millisecond(0);
      time = date;
    }
  }
  return time;
}
